<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //只能传二维数组 而且必须体现出键值
        console.log(new Map([
            ['name', 'Cai'],
            ['age', 18],
        ]));

        //Set Map
        const s = new Set([
            ['name', 'Li'],
            ['age', 100]
        ]);
        console.log(new Map(s));
        console.log(s);


        //Map  复制一个新的Map
        const s2 = new Map([
            ['name', 'LL'],
            ['sex', 'male']
        ]);

        console.log(s2);
        const s3 = new Map(s2);
        console.log(s3);
        console.log(s2 === s3); //false


        console.log(NaN === NaN) //false
            //Map中NaN等于NaN
        const s4 = new Map();
        s4.set(NaN, 1).set(NaN, 2);
        console.log(s4);

        //什么时候使用Map
        //如果只是需要key-value的结构，或者需要字符串以外的值做键
        //  只有模拟现实世界的实体时，才使用对象
        const person = {};
    </script>
</body>

</html>